$.switchable.addEffect("fade", function(a, b) {
    var c = this, d = c.getCfg(), e = c.getPanels(), f = c.getVisiblePanel(a);
    e.hide(), f.fadeIn(1e3 * d.speed, b);
}), $.switchable.addEffect("scroll", function(a, b) {
    var c = this, d = c.getCfg(), e = c.getVisiblePanel(a), f = c.getPanels().parent(), g = c.getIndex(), h = c.getTriggers().length - 1, i = 0 === g && a === h || g === h && 0 === a, j = 0 === g && a === h ? !0 : !1, k = d.vertical ? {
        top: -e.position().top
    } : {
        left: -e.position().left
    };
    f.is(":animated") && f.stop(!0), f.animate(k, 1e3 * d.speed, d.easing, function() {
        b.call(), i && c.resetPosition(j);
    });
}), function(a) {
    var b = a.switchable;
    b.plugin = b.plugin || {}, b.plugin.autoplay = {
        cfg: {
            autoplay: !0,
            interval: 3,
            autopause: !0,
            api: !1
        }
    }, a.fn.autoplay = function(c) {
        "number" == typeof c && (c = {
            interval: c
        });
        var e, d = a.extend({}, b.plugin.autoplay.cfg);
        return a.extend(d, c), this.each(function() {
            var c, f, g, b = a(this).switchable();
            b && (e = b), g = !0, b.play = function() {
                c || (g = !1, c = setInterval(function() {
                    b.next();
                }, 1e3 * d.interval), b.next());
            }, b.pause = function() {
                c = clearInterval(c);
            }, b.stop = function() {
                b.pause(), g = !0;
            }, d.autopause && b.getPanels().hover(function() {
                b.pause(), clearTimeout(f);
            }, function() {
                g || (f = setTimeout(b.play, 1e3 * d.interval));
            }), d.autoplay && setTimeout(b.play, 1e3 * d.interval);
        }), d.api ? e : this;
    };
}(jQuery), function(a) {
    a.fn.carousel = function() {
        return this.each(function() {
            var b = a(this).switchable(), c = b.getCfg(), d = b.getPanels(), e = d.parent(), f = b.getTriggers().length - 1, g = d.slice(0, c.steps), h = d.slice(f * c.steps), i = c.vertical ? h.position().top : h.position().left, j = c.vertical ? "top" : "left", k = d.length > c.visible, l = 0;
            d.css("position", "relative").each(function() {
                l += c.vertical ? a(this).outerHeight(!0) : a(this).outerWidth(!0);
            }), k && h.length < c.visible && e.append(d.slice(0, c.visible).clone().addClass("clone")), 
            a.extend(b, {
                move: function(a) {
                    return e.is(":animated") || !k ? this : 0 > a ? (this.adjustPosition(!0), this.click(f)) : a > f ? (this.adjustPosition(!1), 
                    this.click(0)) : this.click(a);
                },
                adjustPosition: function(b) {
                    var c = b ? h : g;
                    a.each(c, function() {
                        a(this).css(j, b ? -l : l + "px");
                    });
                },
                resetPosition: function(b) {
                    var c = b ? h : g;
                    a.each(c, function() {
                        a(this).css(j, "0px");
                    }), e.css(j, b ? -i : "0px");
                }
            });
        }), this;
    };
}(jQuery);